New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ms-cloudpack/task-reporter

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ms-cloudpack/task-reporter

Helpers for logging tasks to the console.

  • 0.15.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
decreased by-7.7%
Maintainers
0
Weekly downloads
 
Created
Source

@ms-cloudpack/task-reporter

A library for standardizing how tasks are logged to the console.

Example usage

  1. Create a reporter:
const taskReporter = new TaskReporter({
  productName: `Foobar`,
  version: `1.2.3`,
  description: `running tasks with ${bold(`15`)} workers`,
  showStarted: false,
  showPending: true,
  showCompleted: true,
  showSummary: true,
  showTaskDetails: true,
});
  1. Add tasks with the reporter addTask method:
const task = taskReporter.addTask(`build something`, /* initially idle */ true);

// When you are starting the task, you can call start:
try {
  task.start();
} finally {
  task.complete({ status: 'complete' /* etc */ });
}
  1. You can use various formatting helpers to spice up the colorization and formatting of your logging:
// Fail example, with provide details:
import { bulletedList } from '@ms-cloudpack/task-reporter';

task.complete({
  status: 'fail',
  message: 'Reason',
  details: bulletedList(['Name: value', 'Errors:', ['sub-bullet things', 'etc'], 'Warnings', ['warn1', etc]]),
});

A variety of helper functions are available for formatting.

import { cyan, bold, red } from '@ms-cloudpack/task-reporter';

task.complete('fail', { message: cyan(bold(`I am an ${red(`error`)}`)) });
  1. When all your tasks are completed, or if you encountered an exit-early scenario, call reporter.complete('reason') to end task logging:
// You can instruct the reporter to complete when all tasks are done.
reporter.completeWhenTasksDone();

// Or, you can manually tell it to complete at any point. For example, you may want to complete things when the
// users hits ctrl-c. Prematurely completing means pending tasks will be skipped and running tasks will be aborted.
process.on('SIGINT', () => {
  reporter.complete('User hit Ctrl-C');
});

FAQs

Package last updated on 08 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc